float angle = 0;
boolean animate = true;
boolean over = false;

void setup() {
  size(200, 200);
  frameRate(30);
}

void draw() {
  if (mouseX > 10 && mouseX < 60 && mouseY > 10 && mouseY < 60) {
    over = true;
  } else { 
    over = false;
  }
  
  background(#ffffff);
  translate(35, 35);
  rotate(angle);
  fill(#ff0000);
  stroke(#000000);
  rect(-25, -25, 50, 50);
  
  if (animate) {
    angle += 0.05;
  }
}

void mouseClicked() {
  if (over) {
    animate = !animate;
  }
}